home *** CD-ROM | disk | FTP | other *** search
/ Euroscene 2 / Euroscene 2.iso / USEFUL / DeliTracker130 / Developer / Developer.run / Examples / TestPlayer.s < prev    next >
Encoding:
Text File  |  1992-09-23  |  10.9 KB  |  438 lines

  1. **
  2. **    Testplayer.s
  3. **
  4. **    A sample player that visually reports DeliTracker's actions
  5. **    within external players.
  6. **
  7. **    Use the source as a skeleton model for your own players.
  8. **    Refer to the sample sources for additional information.
  9. **
  10. **    Once assembled, load this player into DeliTracker, and try
  11. **    playing the file 'testmodule'.  It is only a textfile with
  12. **    the word "TEST" at the beginning.  Notice now that
  13. **    DeliTracker's actions on the module are visible.  This should
  14. **    aid you in your coding sequences.
  15. **
  16. **    Original source by Peter Kunath and Frank Riffel of Delirium.
  17. **
  18. **    English, comments, and general banter by Kevin Dackiw.
  19. **
  20. **    Have any problems/concerns/ideas?  Feel free to contact the
  21. **    authors:
  22. **
  23. **    Frank Riffel
  24. **    Merkstr. 27
  25. **    8129 Wessobrunn
  26. **    Germany
  27. **
  28. **    Or myself:
  29. **
  30. **    Kevin Dackiw
  31. **    sikorsky@bode.ee.ualberta.ca (preferred)
  32. **    kevind@ersys.edmonton.ab.ca
  33. **
  34.  
  35.     incdir    "includes:"
  36.     include    "misc/DeliPlayer.i"
  37.  
  38. _LVOOldOpenLibrary    EQU -408            ; exec library offsets
  39. _LVOCloseLibrary    EQU -414
  40.  
  41. _LVOTextRequest        EQU -174            ; offset for TextRequest in Req.
  42.  
  43. ;
  44. ;
  45.     SECTION Player,Code
  46. ;
  47. ;
  48.     PLAYERHEADER PlayerTagArray            ; define start of header
  49.  
  50.     dc.b '$VER: TestPlayer V1.15 (29 Jul 92)',0    ; for OS 2.0 version command
  51.     even
  52.  
  53. PlayerTagArray
  54.     dc.l    DTP_PlayerVersion,1            ; define all the tags
  55.     dc.l    DTP_PlayerName,PName            ; for the player
  56.     dc.l    DTP_Creator,CName
  57.     dc.l    DTP_Check2,Chk                ; omit any unused
  58.     dc.l    DTP_Config,Config            ; functions as
  59.     dc.l    DTP_UserConfig,UserConfig        ; needed!
  60.     dc.l    DTP_SubSongRange,SubSong
  61.     dc.l    DTP_InitPlayer,InitPlay
  62.     dc.l    DTP_EndPlayer,EndPlay
  63.     dc.l    DTP_InitSound,InitSnd
  64.     dc.l    DTP_EndSound,EndSnd
  65.     dc.l    DTP_StartInt,StartSnd
  66.     dc.l    DTP_StopInt,StopSnd
  67.     dc.l    DTP_Volume,Volume
  68.     dc.l    DTP_Balance,Balance
  69.     dc.l    DTP_Faster,Faster
  70.     dc.l    DTP_Slower,Slower
  71.     dc.l    DTP_PrevPatt,PrevPatt
  72.     dc.l    DTP_NextPatt,NextPatt
  73.     dc.l    DTP_PrevSong,PrevSub
  74.     dc.l    DTP_NextSong,NextSub
  75.     dc.l    TAG_DONE                ; signify end of tags
  76.  
  77. *-----------------------------------------------------------------------*
  78. ;
  79. ; Playername / creatorname and textstructure for our requesters
  80. ;
  81. *-----------------------------------------------------------------------*
  82.  
  83. PName    dc.b    'TestPlayer',0
  84. CName    dc.b    'Written by Delirium for Testpurposes',0
  85.     even
  86.  
  87. reqname        dc.b 'req.library',0
  88.     even
  89.  
  90. TextStruct
  91.     dc.l    0                    ; ^Text
  92.     dc.l    0                    ; ^ParamList
  93.     dc.l    0                    ; ^Window
  94.     dc.l    0                    ; ^MiddleText
  95.     dc.l    0                    ; ^PositiveText
  96.     dc.l    OKTxt                    ; ^NegativeText
  97.     dc.l    TitleTxt                ; ^Title
  98.     dc.w    $ffff                    ; KeyMask
  99.     dc.w    0                    ; textcol
  100.     dc.w    0                    ; detailcol
  101.     dc.w    0                    ; blockcol
  102.     dc.w    0                    ; versionnumber
  103.     dc.w    0                    ; Timeout
  104.     dc.l    0                    ; abortmask
  105.     dc.l    0                    ; reserved
  106.  
  107. OKTxt
  108.     dc.b    '  OK  ',0
  109.  
  110. TitleTxt
  111.     dc.b    'Information',0
  112.  
  113. InitTxt1
  114.     dc.b    10
  115.     dc.b    'InitPlayer routine called.',10,10
  116.     dc.b    'This routine is called every time a new module is loaded.',10
  117.     dc.b    'The audiochannels should be allocated here, and any',10
  118.     dc.b    'player specific initialization should be performed.',10
  119.     dc.b    0
  120.  
  121. EndTxt1
  122.     dc.b    10
  123.     dc.b    'EndPlayer routine called.',10,10
  124.     dc.b    'This routine is called every time a module is killed',10
  125.     dc.b    '(removed from memory).  Player specific cleanup routines',10
  126.     dc.b    'are performed here, and the audiochannels should be',10
  127.     dc.b    'released at this point.',10
  128.     dc.b    0
  129.  
  130. InitTxt2
  131.     dc.b    10
  132.     dc.b    'InitSound routine called.',10,10
  133.     dc.b    'This routine handles the initialization of the module.',10
  134.     dc.b    0
  135.  
  136. EndTxt2
  137.     dc.b    10
  138.     dc.b    'EndSound routine called.',10,10
  139.     dc.b    'This routine clears the audioregisters.',10
  140.     dc.b    0
  141.  
  142. StartTxt
  143.     dc.b    10
  144.     dc.b    'StartSound routine called.',10,10
  145.     dc.b    'This code must start the sound interrupts.',10
  146.     dc.b    'If you use the internal DeliTracker routines, you must',10
  147.     dc.b    'omit this entry from the TagArray.',10
  148.     dc.b    0
  149.  
  150. StopTxt
  151.     dc.b    10
  152.     dc.b    'StopSound routine called.',10,10
  153.     dc.b    'This code must stop the sound interrupts.',10
  154.     dc.b    'If you use the internal DeliTracker routines, you must',10
  155.     dc.b    'omit this entry from the TagArray.',10
  156.     dc.b    0
  157.  
  158. InfoTxt1
  159.     dc.b    10
  160.     dc.b    'UserConfig routine called.',10,10
  161.     dc.b    'This routine is for the use of advanced players.',10
  162.     dc.b    'For example, if your player needs access to a directory',10
  163.     dc.b    'of instruments, this routine could prompt the user with',10
  164.     dc.b    'a requester for the path to the instruments.  Additionally',10
  165.     dc.b    'the path could then be saved in a custom config file, such',10
  166.     dc.b    'as s:<playername>.config.  Any future runs of the player',10
  167.     dc.b    'would only then have to fetch the path from its config file.',10
  168.     dc.b    'This custom config file must be accessed from the Config routine.',10
  169.     dc.b    0
  170.  
  171. InfoTxt2
  172.     dc.b    10
  173.     dc.b    'ConfigPlayer routine called.',10,10
  174.     dc.b    'This routine is entered after the player is loaded.',10
  175.     dc.b    'At this point you may load a custom config file to fetch',10
  176.     dc.b    'such things as a default instrument path, and the like.',10
  177.     dc.b    0
  178.  
  179. InfoTxt3
  180.     dc.b    10
  181.     dc.b    'NextPattern routine called.',10,10
  182.     dc.b    'This routine skips ahead one pattern in the module.',10
  183.     dc.b    0
  184.  
  185. InfoTxt4
  186.     dc.b    10
  187.     dc.b    'PrevPattern routine called.',10,10
  188.     dc.b    'This routine skips back one pattern in the module.',10
  189.     dc.b    0
  190.  
  191. InfoTxt5
  192.     dc.b    10
  193.     dc.b    'NextSubsong routine called.',10,10
  194.     dc.b    'This routine jumps to the next subsong (if supported).',10
  195.     dc.b    0
  196.  
  197. InfoTxt6
  198.     dc.b    10
  199.     dc.b    'PrevSubsong routine called.',10,10
  200.     dc.b    'This routine jumps to the previous subsong (if supported).',10
  201.     dc.b    0
  202.  
  203. InfoTxt7
  204.     dc.b    10
  205.     dc.b    'PlayFaster routine called.',10,10
  206.     dc.b    'This routine increases the playspeed.',10
  207.     dc.b    0
  208.  
  209. InfoTxt8
  210.     dc.b    10
  211.     dc.b    'PlaySlower routine called.',10,10
  212.     dc.b    'This routine decreases the playspeed.',10
  213.     dc.b    0
  214.  
  215. InfoTxt9
  216.     dc.b    10
  217.     dc.b    'SubSong routine called.',10,10
  218.     dc.b    'This routine must determine the min & max subsong number.',10
  219.     dc.b    0
  220.  
  221. InfoTxt10
  222.     dc.b    10
  223.     dc.b    'Volume routine called.',10,10
  224.     dc.b    'This routine controls the volume.',10
  225.     dc.b    0
  226.  
  227. InfoTxt11
  228.     dc.b    10
  229.     dc.b    'Balance routine called.',10,10
  230.     dc.b    'This routine controls the balance.',10
  231.     dc.b    0
  232.  
  233.     even
  234.  
  235. *-----------------------------------------------------------------------*
  236. ;
  237. ; Check if the module is a TestPlayer-Module (THIS ROUTINE MUST EXIST!!!)
  238. ;
  239. *-----------------------------------------------------------------------*
  240.  
  241. Chk    move.l    dtg_ChkData(a5),a0            ; get module base from DT
  242.     moveq    #0,d0                    ; clear register
  243.     cmpi.l    #'TEST',(a0)                ; supported type ?
  244.     sne    d0                    ; no - signal false
  245.     rts                        ; leave
  246.  
  247.  
  248. *-----------------------------------------------------------------------*
  249. ;
  250. ; Initialize the player
  251. ;
  252. *-----------------------------------------------------------------------*
  253.  
  254. InitPlay
  255.     lea    InitTxt1(pc),a2                ; fetch text
  256.     bsr    DisplayMsg                ; output
  257.     moveq    #0,d0                    ; no error
  258.     rts
  259.  
  260.  
  261. *-----------------------------------------------------------------------*
  262. ;
  263. ; Clean up the player
  264. ;
  265. *-----------------------------------------------------------------------*
  266.  
  267. EndPlay
  268.     lea    EndTxt1(pc),a2                ; fetch text
  269.     bra    DisplayMsg                ; output
  270.  
  271.  
  272. *-----------------------------------------------------------------------*
  273. ;
  274. ; Initialize the module
  275. ;
  276. *-----------------------------------------------------------------------*
  277.  
  278. InitSnd
  279.     lea    InitTxt2(pc),a2                ; fetch text
  280.     bra    DisplayMsg                ; output
  281.  
  282.  
  283. *-----------------------------------------------------------------------*
  284. ;
  285. ; End sound
  286. ;
  287. *-----------------------------------------------------------------------*
  288.  
  289. EndSnd
  290.     lea    EndTxt2(pc),a2                ; fetch text
  291.     bra    DisplayMsg                ; output
  292.  
  293.  
  294. *-----------------------------------------------------------------------*
  295. ;
  296. ; Start interrupts
  297. ;
  298. *-----------------------------------------------------------------------*
  299.  
  300. StartSnd
  301.     lea    StartTxt(pc),a2                ; fetch text
  302.     bra    DisplayMsg                ; output
  303.  
  304.  
  305. *-----------------------------------------------------------------------*
  306. ;
  307. ; Start interrupts
  308. ;
  309. *-----------------------------------------------------------------------*
  310.  
  311. StopSnd
  312.     lea    StopTxt(pc),a2                ; fetch text
  313.     bra    DisplayMsg                ; output
  314.  
  315.  
  316. *-----------------------------------------------------------------------*
  317. ;
  318. ; IMPORTANT NOTE:
  319. ;    There is a BIG difference between the »Config« and the
  320. ;    »UserConfig« Routine !!! The Config routine is immediately
  321. ;    called after that the Player is loaded. It is used to
  322. ;    configure player (e.g. load config file and set pathes)!
  323. ;    The UserConfig routine is only called if the User selects
  324. ;    the player in the PrefWindow and presses the Config Player
  325. ;    GADGET. This routine is thought as a method of getting
  326. ;    informations (playerspecific preferences) from the user
  327. ;    (e.g. pathes for instruments or maximum memory usage).
  328. ;    The difference between Config and InitPlayer is that
  329. ;    Config is called ONCE the player is loaded and that
  330. ;    InitPlayer is called every time a module is played.
  331. ;
  332. *-----------------------------------------------------------------------*
  333. ;
  334. ; get/set playerspecific preferences (configuration routines)
  335. ;
  336. *-----------------------------------------------------------------------*
  337.  
  338. UserConfig
  339.     lea    InfoTxt1(pc),a2                ; fetch text
  340.     bra    DisplayMsg                ; output
  341.  
  342. Config
  343.     lea    InfoTxt2(pc),a2                ; fetch text
  344.     bsr    DisplayMsg                ; output
  345.     moveq    #0,d0                    ; no error
  346.     rts
  347.  
  348.  
  349. *-----------------------------------------------------------------------*
  350. ;
  351. ; Patterncontrol
  352. ;
  353. *-----------------------------------------------------------------------*
  354.  
  355. NextPatt
  356.     lea    InfoTxt3(pc),a2                ; fetch text
  357.     bra    DisplayMsg                ; output
  358.  
  359. PrevPatt
  360.     lea    InfoTxt4(pc),a2                ; fetch text
  361.     bra    DisplayMsg                ; output
  362.  
  363.  
  364. *-----------------------------------------------------------------------*
  365. ;
  366. ; Subsongcontrol
  367. ;
  368. *-----------------------------------------------------------------------*
  369.  
  370. SubSong
  371.     lea    InfoTxt9(pc),a2                ; fetch text
  372.     bra    DisplayMsg                ; output
  373.  
  374. NextSub
  375.     lea    InfoTxt5(pc),a2                ; fetch text
  376.     bra    DisplayMsg                ; output
  377.  
  378. PrevSub
  379.     lea    InfoTxt6(pc),a2                ; fetch text
  380.     bra    DisplayMsg                ; output
  381.  
  382.  
  383. *-----------------------------------------------------------------------*
  384. ;
  385. ; Speedcontrol
  386. ;
  387. *-----------------------------------------------------------------------*
  388.  
  389. Faster
  390.     lea    InfoTxt7(pc),a2                ; fetch text
  391.     bra    DisplayMsg                ; output
  392.  
  393. Slower
  394.     lea    InfoTxt8(pc),a2                ; fetch text
  395.     bra    DisplayMsg                ; output
  396.  
  397.  
  398. *-----------------------------------------------------------------------*
  399. ;
  400. ; Volume & Balance Control
  401. ;
  402. *-----------------------------------------------------------------------*
  403.  
  404. Volume
  405.     lea    InfoTxt10(pc),a2            ; fetch text
  406.     bra    DisplayMsg                ; output
  407.  
  408. Balance
  409.     lea    InfoTxt11(pc),a2            ; fetch text
  410.     bra    DisplayMsg                ; output
  411.  
  412.  
  413. *-----------------------------------------------------------------------*
  414. ;
  415. ; Subroutines
  416. ;
  417. *-----------------------------------------------------------------------*
  418.  
  419. DisplayMsg
  420.     lea    reqname(pc),a1
  421.     move.l    4.w,a6
  422.     jsr    _LVOOldOpenLibrary(a6)            ; open req.library
  423.     tst.l    d0
  424.     beq.s    DisplayEnd                ; library open failed
  425.  
  426.     lea    TextStruct(pc),a0            ; address of text structure
  427.     move.l    a2,(a0)                    ; copy text pointer to block
  428.     move.l    d0,a6                    ; get ReqBase address
  429.     jsr    _LVOTextRequest(a6)            ; print the message
  430.  
  431.     move.l    a6,a1
  432.     move.l    4.w,a6
  433.     jsr    _LVOCloseLibrary(a6)            ; close req.library
  434. DisplayEnd
  435.     rts                        ; bye!
  436.  
  437.     END
  438.